<?php

namespace app\controller;
use dh2y\qrcode\QRcode;
use Intervention\Image\Image;
use Intervention\Image\ImageManager;

class phpcode
{
    public function index(){
        $qrCode = new QrCode();
        $pathname = date('Ymdhis');
        $day = date('Ymd');
        $company_id = 2;
        $product_id = 1;
        $cache_shaf = config('app')['cache_shaf'];
//        $company_id = openssl_encrypt($company_id, 'DES-ECB', $cache_shaf, 0);
//        $product_id = openssl_encrypt($product_id, 'DES-ECB', $cache_shaf, 0);
//        $new_day = openssl_encrypt($day, 'DES-ECB', $cache_shaf, 0);


//        $option = 'I23'.$company_id.'-'.$product_id.'-'.$day;

        /**批次    --23I或202309或2309
         * 企业id  -- 2=>0002
         * 产品id  -- 15=>0000 0015
         * 00000000001500002I2353
         * 0000 0000 0015    00002      I23     53
         * 产品的id不足补0   单位id不足补0  批次     云南省
         */
        $option = '999999999999999L9999';//code_str_pad(12,$product_id).code_str_pad(5,$company_id).'I23'.'53';
        $option =  openssl_encrypt(json_encode($option), 'DES-ECB', $cache_shaf, 0);


//        $option = openssl_encrypt(123, 'DES-ECB', $cache_shaf, 0);


        $option =  openssl_decrypt($option, 'DES-ECB', $cache_shaf, 0);



        $dir = config('app')['cache_dir'].'/'.$day;
        if (!file_exists($dir)) {
            mkdir($dir, 0777, true);
        }

        $qrCode->png($option,$pathname,4.2,'H');

        $qrCode->background(50,150,$_SERVER['DOCUMENT_ROOT'].'/static/2.png',$day.'/'.$pathname);
        echo $qrCode->entry();


    }

    public function info(){
        $code = input('get.c');
       return re_success('sss',$code);
    }

}